﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MessageQuque.Common
{
    public static class ModelExtensions
    {
        /// <summary>
        /// 获取类中的属性值
        /// </summary>
        /// <param name="FieldName"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static object GetValue(this object obj, string fieldName)
        {
            try
            {
                Type Ts = obj.GetType();
                object o = Ts.GetProperty(fieldName).GetValue(obj, null);
                return o;
            }
            catch
            {
                return null;
            }
        }
    }
}
